package chapter2;

import java.util.ArrayList;
import java.util.List;

public class Apple {
    private int weight;
    private String colour;

    public int getWeight() {
        return weight;
    }

    public void setWeight(int weight) {
        this.weight = weight;
    }

    public String getColour() {
        return colour;
    }

    public void setColour(String colour) {
        this.colour = colour;
    }

    public static List<Apple> filterApples(List<Apple> inventory,ApplePredicate predicate){
        List<Apple> result = new ArrayList<>();
        for(Apple apple: inventory){
            if(predicate.test(apple)){
                result.add(apple);
            };
        }
        return result;
    }

    public Apple(int weight, String colour) {
        this.weight = weight;
        this.colour = colour;
    }

    public Apple(int weight) {
        this.weight = weight;
    }

    public Apple() {
    }

    @Override
    public String toString() {
        return "Apple{" +
                "weight=" + weight +
                ", colour='" + colour + '\'' +
                '}';
    }
}
